package com.charlotte.study.gupao.adapter.login.v1;


/**
 * 返回数据基础类
 * @author Solrsky
 * @date 2019/1/14
 */
public class BaseResponse {

    /**
     * 元数据
     */
    private Meta meta;

    /**
     * 返回数据
     */
    private Object data;

    public Meta getMeta() {
        return meta;
    }

    public Object getData() {
        return data;
    }


    public BaseResponse(String code, String msg, Object data) {
        this.meta = new Meta(true, code, msg);
        this.data = data;
    }

    /**
     * 判断是否成功
     * @return
     */
    public boolean isSuccess(){
        if(null != this.meta){
            return this.meta.success;
        }else{
            return false;
        }
    }

    /**
     * 返回msg
     * @return
     */
    public String getMsg(){
        if(null != this.meta){
            return this.meta.msg;
        }
        return null;
    }

    /**
     * 元数据内部类
     */
    private class Meta{

        private boolean success;
        private String code;
        private String msg;

        Meta(boolean success, String code, String msg) {
            this.success = success;
            this.code = code;
            this.msg = msg;
        }

        public Meta(boolean success) {
            this.success = success;
        }

        Meta(boolean success, String msg) {
            this.success = success;
            this.msg = msg;
        }

        public boolean isSuccess() {
            return success;
        }

        public String getCode() {
            return code;
        }

        public String getMsg() {
            return msg;
        }

    }
}
